unit fEmployeeLocation;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
  cxStyles, dxSkinsCore, dxSkinCaramel, dxSkinOffice2010Silver, dxSkinSeven,
  dxSkinscxPCPainter, cxCustomData, cxFilter, cxData, cxDataStorage, cxEdit, DB,
  cxDBData, cxGridLevel, cxGridCustomTableView, cxGridTableView,
  cxGridBandedTableView, cxGridDBBandedTableView, cxClasses, cxGridCustomView,
  cxGrid, uDADataTable, uDARemoteDataAdapter, uDAScriptingProvider,
  uDAMemDataTable, uDAInterfaces, dImages, dxSkinsdxBarPainter, dxBar,
  dxBarExtItems, cxCalendar, cxBarEditItem;

type
  TfmEmployeeLocation = class(TForm)
    dsBrowser: TDADataSource;
    tblBrowser: TDAMemDataTable;
    rdaBrowser: TDARemoteDataAdapter;
    grdBrowser: TcxGrid;
    tvBrowser: TcxGridDBBandedTableView;
    tvBrowserId: TcxGridDBBandedColumn;
    tvBrowserColumn1: TcxGridDBBandedColumn;
    tvBrowserColumn2: TcxGridDBBandedColumn;
    tvBrowserColumn3: TcxGridDBBandedColumn;
    tvBrowserColumn4: TcxGridDBBandedColumn;
    tvBrowserColumn6: TcxGridDBBandedColumn;
    tvBrowserColumn5: TcxGridDBBandedColumn;
    tvBrowserColumn7: TcxGridDBBandedColumn;
    lvBrowser: TcxGridLevel;
    dxBarManager1: TdxBarManager;
    dxBarManager1Bar1: TdxBar;
    bbtnPrev: TdxBarButton;
    bbtnNext: TdxBarButton;
    edtDate: TdxBarDateCombo;
    procedure FormShow(Sender: TObject);
    procedure bbtnPrevClick(Sender: TObject);
    procedure bbtnNextClick(Sender: TObject);
    procedure edtDateChange(Sender: TObject);
  private
    { Private declarations }
    fCurrentDate: TDateTime;
  public
    { Public declarations }
  end;

var
  fmEmployeeLocation: TfmEmployeeLocation;

implementation

{$R *.dfm}

procedure TfmEmployeeLocation.bbtnNextClick(Sender: TObject);
begin
  fCurrentDate := fCurrentDate + 1;
  edtDate.Date := fCurrentDate;
end;

procedure TfmEmployeeLocation.bbtnPrevClick(Sender: TObject);
begin
  fCurrentDate := fCurrentDate - 1;
  edtDate.Date := fCurrentDate;  
end;

procedure TfmEmployeeLocation.edtDateChange(Sender: TObject);
var
  sql: string;
begin
  sql := 'exec upc_public_GenLocation '+ QuotedStr(DateToStr(edtDate.Date));

    tblBrowser.Close;
    rdaBrowser.GetDataCall.ParamByName('aSQLText').AsString := AnsiToUtf8(sql);
    tblBrowser.MaxRecords := -1;
    rdaBrowser.Fill([tblBrowser], true, true);

end;

procedure TfmEmployeeLocation.FormShow(Sender: TObject);
begin
  edtDate.Date := Date;
  fCurrentDate := Date;
end;

end.
